#ifndef USEROBJECT_H
#define USEROBJECT_H

#include <QSharedPointer>
#include <qgl.h>

class QGLShaderProgram;
class GLTexture;

class UserObject
{
public:
    UserObject();

    void loadProgram(const QByteArray &vertexShaderSrc, const QByteArray &fragmentShaderSrc);

    //attribute locations
    void setPositionLocation(GLint location) { _positionLocation = location; }
    GLint positionLocation() { return _positionLocation; }
    void setTexCoordLocation(GLint location) { _texCoordLocation = location; }
    GLint texCoordLocation() { return _texCoordLocation; }

    // sampler location
    void setSamplerLocation(GLint location) { _samplerLocation = location; }
    GLint samplerLocation() { return _samplerLocation; }

    void setMvpLocation(GLint location) { _mvpLocation = location; }
    GLint mvpLocation() { return _mvpLocation; }

    // offset location
    void setOffsetLocation(GLint location) { _offsetLocation = location; }
    GLint offsetLocation() { return _offsetLocation; }

    // shader program
    QSharedPointer<QGLShaderProgram> programObject() { return _programObject; }

    //texture object
    void setTexture(QSharedPointer<GLTexture> tex) { _texture = tex; }
    QSharedPointer<GLTexture> texture() { return _texture; }

private:
    QSharedPointer<QGLShaderProgram> _programObject;
    GLint _positionLocation;
    GLint _texCoordLocation;
    GLint _samplerLocation;
    GLint _offsetLocation;
    GLint _mvpLocation;
    QSharedPointer<GLTexture> _texture;
};

#endif // USEROBJECT_H
